#include <iostream>
#include <cstdio>
#include <unistd.h>  /* dup2: just for test */
#include <seccomp.h> /* libseccomp */
//compile: g++ syscall_limit.cpp -lseccomp
using namespace std;
int onUpdate(int generator_i, int generator_u, int payload_i, int payload_u);
int main(){
  // Init the filter
  scmp_filter_ctx ctx;
  ctx = seccomp_init(SCMP_ACT_KILL); // default action: kill

  // setup basic whitelist
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigreturn), 0);
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit), 0);
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0);
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0);
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0);
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(fstat), 0);
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(lseek), 0);
  seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mmap), 0);

  // build and load the filter
  seccomp_load(ctx);
  int generator_i, generator_u, payload_i, payload_u;
  cin>>generator_i>>generator_u>>payload_i>>payload_u;
  cout<<onUpdate(generator_i, generator_u, payload_i, payload_u);
  return 0;
}
